import os
import redis

class Config:
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:237297@127.0.0.1:3306/bs?charset=utf8'
    SQLALCHEMY_MODIFICATIONS = True
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    SQLALCHEMY_ECHO = True
    ###############
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # for session
    SECRET_KEY = 'rental_platform_key'

    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # 关闭浏览器session就失效
    SESSION_PERMANENT = True
    # 保存到redis的session数的名称前缀
    SESSION_KEY_PREFIX = "session:"
    # flask-session使用的参数
    SESSION_TYPE = "redis"
    SESSION_USE_SIGNER = True
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 86400

    # flask-session中用于响应头set-cookie中samesite默认为lax，而无法跨域的问题（vue）
    SESSION_COOKIE_SAMESITE = 'None'
    SESSION_COOKIE_SECURE = True